package gladrag;

import java.util.ArrayList;
import java.util.Iterator;

public class Star implements Observable {

	private ArrayList<Fan> myFans = new ArrayList<Fan>();
	private String news;
	
	@Override
	public void registerObserver(Fan fan) {
		this.myFans.add(fan);
	}

	@Override
	public void removeObserver(Fan fan) {
		this.myFans.remove(fan);		
	}

	@Override
	public void notifyObservers() {
		Fan aFan;
		Iterator<Fan> iter = this.myFans.iterator();
		while (iter.hasNext()) {
			aFan = (Fan)iter.next();
			aFan.update(news);
		}
	}

	public void freshNews(String news) {
		setNews(news);
		notifyObservers();
	}
	
	public void setNews(String news) {
		this.news = news;
	}
}
